#ifndef API_H_
#define API_H_

#include "../data_link/data_link.h"

#define BAUDRATE B38400
#define _POSIX_SOURCE 1 /* POSIX compliant source */
#define FALSE 0
#define TRUE 1
#define BUFF_SIZE 255

#define DEBUG 1

// Sender's Declarations
 
#define SENDER 0
 
 // Receiver's Declarations
 
#define RECEIVER 1

// Ports Available
#define TTYS0 0
#define TTYS1 1

 // State Machine Declarations
#define NULL_STATE -1
#define F1_STATE 0
#define A_STATE 1
#define C_STATE 2
#define BCC_STATE 3
#define F2_STATE 4

#define N_STATES 6


// Packet Declarations
#define DATA_SIZE 256

#define DATA_PACKET 0x00
#define START_PACKET 0x01
#define END_PACKET 0x02
#define FILE_SIZE 0x00
#define FILE_NAME 0x01

#define HEADER_SIZE 4

#define PACKET_CONTROL_START 1
#define PACKET_CONTROL_END 3

#define START_CONTROL_PACKET -1
#define END_CONTROL_PACKET -3
#define CONTROL_PACKET_PARTIAL_SIZE 8

/**
@param port device identifier (TTYS0 or TTYS1)
@param flag entity identifier (RECEIVER or SENDER)
*/
int llopen(int port, char flag);

/**
@param fd file descriptor of device (returned by llopen)
*/
int llclose(int fd);

/**
@param fd data connection identifier
@param buffer string to transmit
@param length size of buffer
*/
int llwrite(int fd, char *buffer, int length);

/**
@param fd data connection identifier
@param buffer string to be 
@param length size of buffer
*/
int llread(int fd, char *buffer);

#endif // API_H_
